<!--
 * Copyright (c) 2009 The Chromium Authors. All rights reserved.  Use of this
 * source code is governed by a BSD-style license that can be found in the
 * LICENSE file.
-->
<html>
<head>
<script>  
  function executeShare(tab_id, subject, body, selection) {    
    var action_url = "http://pythias01.appspot.com/share/create/share?"
    if (body.length > 0)
      action_url += "link=" + encodeURIComponent(body) + "&";

    if (subject.length > 0)
      action_url += "title=" + encodeURIComponent(subject) + "&";
    
    //var selection = window.getSelection().toString();
    //if (selection.length > 0) {
    //  action_url += "description=" + encodeURIComponent(selection);
    //}
    
    console.log('Share url: ' + action_url);
    chrome.tabs.create({ url: action_url });
  }

  // Called when the user clicks on the browser action icon.
  chrome.browserAction.onClicked.addListener(function(tab) {
    executeShare(tab.id, "", tab.url, "");
  });
  
</script>
</head>
</html>
